<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="preserveSpaces" select="'no'" />
  <xsl:output method="html"/>

  <!-- ###################################################################################
        Root
        Builds out HTML headers and envokes detail for entire report.
     ################################################################################### -->
  <xsl:template match="/">
    <html>
      <head>
        <title>Deployment Report</title>
      </head>
      <body>
        <xsl:call-template name="StyleSheet"/>
        <div class="head" id="head">
          <table width="95%" align="center">
            <tr>
              <td class="headTitle1">Deployment Report</td>
              <!--<td class="headComment">for 7/25/2008</td>-->
            </tr>
          </table>
        </div>
        <div class="grayline">&#160;</div>
        <table border="1" cellpadding="5" cellspacing="0">
          <tr>
            <td class="DefectDetailTitle">OnTime Project: </td>
            <td class="DefectDetailEven">
              <xsl:value-of select="./Deployments/@Project"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Product Release: </td>
            <td class="DefectDetailEven">
              <xsl:value-of select="./Deployments/@Version"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Environment: </td>
            <td class="DefectDetailEven">
              <xsl:value-of select="./Deployments/@Environment"/>
            </td>
          </tr>
        </table>
        <hr/>
        <xsl:apply-templates select="./*"/>
      </body>
    </html>
  </xsl:template>

  <!-- ###################################################################################
        Deployment
     ################################################################################### -->
  <xsl:template match="Deployment">
    <td>
      <div class="head" id="head">
        <table width="95%" align="center">
          <tr>
            <td class="headTitle2">
              <xsl:value-of select="@DeploymentVersion"/>
            </td>
            <td class="headComment">
              <xsl:value-of select="@DeploymentTime"/>
            </td>
          </tr>
        </table>
      </div>
      <table border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td class="inblue">Defects Addressed in Deployment: </td>
          <td class="DefectDetailEven">
            <xsl:value-of select="count(./Defect)"/>
          </td>
        </tr>
      </table>
      <xsl:apply-templates select="./*"/>
    </td>
  </xsl:template>

  <xsl:template match="Defect">
    <td>
      <div>
        <hr/>
        <h4>Defect <xsl:value-of select="@DefectId"/></h4>
        <table border="1" cellpadding="5" cellspacing="0">
          <tr>
            <td class="DefectDetailTitle">Name: </td>
            <td class="DefectDetailEven">
              <xsl:value-of select="@Name"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Priority: </td>
            <td class="DefectDetail">
              <xsl:value-of select="@Priority"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Severity: </td>
            <td class="DefectDetailEven">
              <xsl:value-of select="@Severity"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Status: </td>
            <td class="DefectDetail">
              <xsl:value-of select="@DefectStatus"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Description: </td>
            <td class="DefectDetailEven">
              <xsl:apply-templates select="./Description"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Notes: </td>
            <td class="DefectDetail">
              <xsl:apply-templates select="./Notes"/>
            </td>
          </tr>
          <tr>
            <td class="DefectDetailTitle">Replication Procedures: </td>
            <td class="DefectDetailEven">
              <xsl:apply-templates select="./ReplicationProcedures"/>
            </td>
          </tr>
        </table>
      </div>
    </td>
    <br/>
  </xsl:template>

  <xsl:template match="Description">
    <xsl:value-of select="." disable-output-escaping="yes" />
  </xsl:template>

  <xsl:template match="Notes">
    <xsl:value-of select="." disable-output-escaping="yes" />
  </xsl:template>

  <xsl:template match="ReplicationProcedures">
    <xsl:value-of select="." disable-output-escaping="yes" />
  </xsl:template>



  <!-- ###################################################################################
        clean-string
        
        Recursive replace of spaces with nbsp when $preserveSpaces is 'yes'.
     ################################################################################### -->
  <xsl:template name="clean-string" xml:space="default">
    <xsl:param name="string" />
    <xsl:choose>
      <xsl:when test="$preserveSpaces!='yes'">
        <xsl:value-of select='$string'/>
      </xsl:when>
      <xsl:when test="contains($string,' ')">
        <xsl:value-of select="substring-before($string,' ')" />
        <xsl:copy-of select="'&#160;'" />
        <xsl:call-template name="clean-string">
          <xsl:with-param name="string" select="substring-after($string,' ')" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$string" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <!-- ###################################################################################
        StyleSheet
        
        Generate Style Sheet
     ################################################################################### -->

  <xsl:template name="StyleSheet">
    <style type="text/css">
      /* style for body and font for all items */
      body {
      font-family: Arial, Tahoma, Helvetica;
      color: #000000;
      margin: 10;
      font-size: 9pt;
      background-color: #ffffff;
      }

      td {
      font-size: 9pt;
      }

      th {
      font-size: 9pt;
      }

      div {
      font-size: 9pt;
      }
      a {
      text-decoration:  none;
      color:  #020280;
      }
      /* style for body and font for all items */

      /* main block */
      .main {
      background-color: #ffffff;
      border: solid #cccccc 1px;
      overflow: auto;
      padding: 0;
      margin-top: 5;
      }

      /* bottom blocks */
      .dVisible {
      background-color: #ffffff;
      border: solid #cccccc 1px;
      padding: 0;
      margin-top:0;
      display: block;
      overflow: auto;
      border-top: none;
      }

      /* hidden blocks */
      .dHidden {
      display: none;
      }

      .iHidden {
      display: none;
      }

      /* blue header and gray line under that*/
      .head {
      background-color: #0033CC;
      color: #ffffff;
      }

      .headTitle1 {
      font-size: 24pt;
      font-weight: bold;
      color: #ffffff;
      }

      .headTitle2 {
      font-size: 15pt;
      font-weight: bold;
      color: #ffffff;
      }

      .headComment {
      font-size: 10pt;
      font-weight: bold;
      color: #ffffff;
      text-align: right;
      }

      div.grayline {
      height:4px;
      background-color: #dbdbdb;
      font-size: 1px;
      }

      /* each part title */
      .titl {
      font-weight: bold;
      font-size: 12pt;
      color: #020280;
      }

      .DefectDetailTitle {
      font-weight: bold;
      padding-right: 15;
      padding-bottom: 10;
      font-weight: bold;
      text-align: right;
      vertical-align: top;
      color: #020280;
      }

      .DefectDetail {
      width: 600px;
      padding-bottom: 10;
      vertical-align: top;
      background-color: #FFFFCC;
      }

      .DefectDetailEven {
      width: 600px;
      padding-bottom: 10;
      vertical-align: top;
      }

      .inblue {
      font-weight: bold;
      padding-right: 10;
      color: #020280;
      }
      /* tables for scripts, differences tables in document  */
      table.inner  {
      width: 100%;
      }

      table.inner th {
      border-bottom: solid #000000 2px;
      font-weight: bold;
      padding-top: 2;
      padding-bottom: 2;
      padding-left: 5;
      padding-right: 10;
      text-align: left;
      vertical-align: top;
      }

      table.inner td {
      border-bottom: solid #aaaaaa 1px;
      padding-top: 2;
      padding-bottom: 2;
      padding-left: 5;
      padding-right: 10;
      vertical-align: top;
      font-weight: bold;
      }

      table.inner td#normal {
      font-weight: normal;
      }

      table.inner td#href {
      cursor: pointer;
      }

      table.inner td#red {
      color: #ff0000;
      }

      table.inner td#blue {
      color: #020280;
      }

      table.inner td#blue {
      color: #020280;
      }


      /* script lines styles */
      table.inner td#LineNum {
      text-align: center;
      vertical-align: text-top;
      }

      table.inner td#Same {font-weight: normal; width:48%; }
      table.inner td#SrcOnly {font-weight: normal; background-color: #e0ebfc; color:#008000; width:48%; }
      table.inner td#DstOnly {font-weight: normal; background-color: #e0ebfc; color:#C80000; width:48%; }
      table.inner td#Virtual {font-weight: normal; background-color: #EEEEEE; width:48%; }

      .icon {
      color: #020280;
      font-weight: 900;
      font-size: 15px;
      font-family: Courier;
      text-align: center;
      padding-left: 2;
      padding-right: 2;
      border: solid #020280 1px;
      }

      .handcursor{
      cursor:hand;
      cursor:pointer;
      }

    </style>
  </xsl:template>

</xsl:stylesheet>